package com.muse.genericity;

import java.util.ArrayList;
import java.util.List;

/**
 * 使用List<T> list可以解决：
 */
public class TypeWildcard3 {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("aaa");
        list.add("bbb");
        print(list);

        List<Integer> list2 = new ArrayList<>();
        list2.add(111);
        list2.add(222);
        print(list2);
    }

    public static <T> void print(List<T> list) {
        list.add(list.get(0));
        for (T t : list)
            System.out.println(t);
    }
}
